<?php
/**
 *   駿濤 （xjt@ourstu.com）
 */

function get_pay_method($method){
    switch ($method) {
        case 'alipay_pc_direct':
            return L('_ALIPAY_PC_');
        case 'alipay_wap':
            return L('_ALIPAY_WAP_');
        case 'wx_pub':
            return L('_WX_PUB_');
        case 'wx_pub_qr':
            return L('_WX_PUB_QR_');
        case 'alipay':
            return '支付宝手机';
        case 'alipay_qr':
            return '支付宝扫码';
    }
}



function get_order_status_cn($order_id){
    $status = get_order_status($order_id);
    switch($status){
        case 1: return L('_PAYMENT_SUCCESS_');
        case 2: return L('_PAYMENT_SUCCESS_BUT_DB＿ERROR_');
        case 0:   return L('_NOT_PAID_');
    }
}


function get_order_status($order_id){
    $order = D('PingxxOrder')->getOrder($order_id);
    $record = D('PingxxCharge')->getCharge($order['charge_id']);

    if($record['paid']){
        if($order['payok']){
            return 1;
        }else{
            return 2;
        }
    }else{
        return 0;
    }
}



function get_recharge_type($field){
    $fields_config = modC('RE_FIELD', "", 'Pingxx');
    $fields = json_decode($fields_config,true);
    $res = array_search_key($fields,'FIELD',$field);
    return $res;
}

function get_withdraw_type($field){
    $fields_config = modC('WITHDRAW_FIELD', "", 'Pingxx');
    $fields = json_decode($fields_config,true);
    $res = array_search_key($fields,'FIELD',$field);
    return $res;
}


